home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Localization Tools / Localization using ResEdit™ 3.0 / ResEdit Notes for Developers < prev    next >
Encoding:
Text File  |  1996-08-23  |  7.2 KB  |  164 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                      
  5. Setting up ResEdit EDL and VDL code for View Layouts
  6. Containing Custom View Types                                           
  7.  
  8. The "Plugin for ODF 1" file permits the localization of ODF parts containing most common ODF resoruce types, including standard view layout ('FWvl') resources.  To install the plugin, just drag it to your ResEdit folder.  If you're localizing parts created with ODF 2, use the "Plugin for ODF 2" file instead.
  9.  
  10. The plugin includes code written in two languages supported by ResEdit, the Exploder and Viewer Definition Languages (EDL and VDL).  EDL describes the data model of a resource type, and VDL describes how a graphical editor for that resource type should be laid out.  The code used to edit framework view layout ('FWvl') resources for localization relies on class labels stored within the resource data for information about how it should parse the resource into a series of editable fields.  Support for class labels representing all standard ODF view types is included in the code; however, many developers will want to create their own custom view types derived from the standard types, and will use unique class labels to identify their types.  To modify the plugin to support these changes, it's necessary to make changes to both the EDL and VDL code.
  11.  
  12. Modifying the EDL
  13.  
  14. In order to edit view layouts containing custom views with ResEdit, the 'FWvl' data model must first be modified to accomodate the new types.  To do this, open the 'EDL ' resource named "Resource.FWvl" in the "Plugin for ODF" file.  At the bottom of the EDL code is a Switch statement (shown here in condensed form):
  15.  
  16. Switch(fLabel)
  17. {
  18.     .
  19.     .
  20.     .    
  21.  
  22.     case 'butn':    {Call(FW_RButton);}
  23.     case 'popm': {Call(FW_RPopupMenu);}
  24.     case 'scbr': {Call(FW_RScrollBar);}
  25.  
  26.     .
  27.     .
  28.     .
  29.     
  30.     case 'edvw':
  31.     case 'Pwdv':
  32.     {
  33.         Call(FW_REditView);
  34.     }
  35.     
  36.     case 'Sedv':
  37.     {
  38.         Call(FW_REditView);
  39.         
  40.         Long(fHorizViewID);
  41.         Long(fVertViewID);
  42.         Long(fTextWidth);
  43.     }
  44.     
  45.     case 'Frmv':
  46.     {
  47.         Call(FW_RPictSView);
  48.         
  49.         Word(fPicture2);
  50.         
  51.         List(fRadioClusters, RadioCluster, 3)
  52.             Call(FW_RRadioCluster);  // list of 3 radio clusters
  53.     }
  54. }
  55.  
  56. When one of the standard class labels ('butn', 'popm', etc.) is encountered, the EDL code calls a definition set up for that data type.  If you add a custom type that doesn't add any new data fields to an existing type, you can just insert a case clause with your class label at the appropriate spot in the Switch.  An example of this is shown with the 'Pwdv' type, above.  'Pwdv' represents a custom type used by the ODFForm example for a password field.  It doesn't add any new data to the edit view ('edvw') class, so a new case label was just added that calls the same definition as that for the edit view class.
  57.  
  58. If you create a custom type that adds its own data fields to the resource type, you'll have to add a new case clause to the Switch.  You can have the code in the new clause call the definition for the class from which you're deriving, and follow the call with statements representing your new data.  Examples of this are shown above for the 'Sedv' (derived from FW_REditView) and 'Frmv' (derived from FW_RPictSView) classes.  Some commonly-used statements you may want to use in your EDL code include:
  59.  
  60.         Byte(fieldName);                                                                            One-byte field
  61.         Word(fieldName);                                                                            Two-byte field
  62.         Long(fieldName);                                                                            Four-byte field
  63.         String(fieldName, LengthWord);                    String preceded by two bytes of length information
  64.         Data(fieldName, byteCount);                                byteCount bytes of data of unspecified format
  65.         PadByte();                                                                                                    Skip one byte
  66.         PadWord();                                                                                                    Skip two bytes
  67.         PadLong();                                                                                                    Skip four bytes
  68.  
  69. In addition, you can create lists of elements as follows:
  70.  
  71.         List(fieldName, TypeName, numItems)                                                List containing numItems elements
  72.             elements
  73.  
  74.         List(fieldName, TypeName, OneBasedCount(16))            List preceded by a two-byte item count
  75.             elements
  76.  
  77. As an example, this code from the ODFRC definition for a radio cluster:
  78.  
  79.     integer = $$CountOf(RadioArray);
  80.     array RadioArray
  81.     {
  82.         RadioID:
  83.             longint;
  84.     };
  85.  
  86. ...is expressed in EDL as:
  87.  
  88.     List(fRadioArray, RadioEntry, OneBasedCount(16))
  89.         Long(fRadioID);
  90.  
  91. Modifying the VDL
  92.  
  93. In order for ResEdit to support the editing of 'FWvl' resources containing your custom view layout, you need to make two changes to the VDL.  First, open the 'VDL ' resource named "Resource.FWvl", and scroll down to the named statement called "ViewList":
  94.  
  95. DeclareNamedStatement("ViewList")
  96.     Margin(5, 5, 5, 5)
  97.         DynamicListMargin("Views:", fViews, Width = UseParent)
  98.             DynamicVList(fViews, View, Width = UseParent)
  99.                 Switch(fLabel)
  100.                 {
  101.                     case 'view':
  102.                     case 'suvw':
  103.                     case 'cont':
  104.                     case 'ncnt':
  105.                     case 'butn':
  106.                     case 'popm':
  107.                     case 'scbr':
  108.                     case 'grbx':
  109.                         .
  110.                         .
  111.                         .
  112.  
  113. This named statement is required as a workaround because of a problem placing a recursive "SELF" call in the default clause of a Switch in VDL.  Just add a new case to the Switch containing the class label you selected for your class.  This will enable ResEdit to recognize your custom view type.
  114.  
  115. Finally, scroll down to the bottom of the VDL code (where the main statement is):
  116.  
  117. Margin(2, 2, 2, 2)
  118.     Margin(5, 5, 5, 5, Single)
  119.         Switch(fLabel)
  120.         {
  121.             case 'root':
  122.                 IncludeNamedStatement("FrameLayout");
  123.                         .
  124.                         .
  125.                         .
  126.             case 'edvw':
  127.             case 'Pwdv':
  128.                 IncludeNamedStatement("EditView");
  129.             
  130.             case 'Sedv':
  131.                 IncludeNamedStatement("ScrollingEditView");
  132.                         .
  133.                         .
  134.                         .
  135.             
  136. If your new class doesn't contain any fields that need to be edited for localization beyond those in its parent class, you can just add a new case label in the appropriate place (as shown above for 'edvw' and 'Pwdv').  On the other hand, if you've added localizable data, you need to define a new named statement and add a new case clause that includes that named statement.  You'll want to include the statement corresponding to the base class in your new statement, as shown below for the 'Sedv' class.
  137.  
  138. DeclareNamedStatement("ScrollingEditView")
  139.     VList(Width = UseParent)
  140.     {
  141.         IncludeNamedStatement("EditView");
  142.         
  143.         Spacer(Height = 2);
  144.  
  145.         HList()
  146.         {
  147.             EditText(fVertViewID, Label = "HorizViewID:", Width = 130,
  148.                 LabelWidth = 70, LabelAlignment = Right);
  149.             EditText(fHorizViewID, Label = "VertViewID:", Width = 130,
  150.                 LabelWidth = 70, LabelAlignment = Right);
  151.         }
  152.  
  153.         Spacer(Height = 2);
  154.         
  155.         EditText(fTextWidth, Fixed(16, 16), Label = "TextWidth:", Width = 160,
  156.             LabelWidth = 70, LabelAlignment = Right);        
  157.     }
  158.  
  159. Most of the commands used in VDL are fairly self-explanatory:  VList and HList allow the creation of nestable vertical and horizontal lists, Spacer leaves space in the layout, and EditText creates an editable text box corresponding to the resource field named in its first argument.  For more information, please see the ResEdit documentation.
  160.  
  161.  
  162. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  163. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.
  164.